package cn.edu.zut.service.Impl;

import cn.edu.zut.dao.NoticeDao;
import cn.edu.zut.domain.Notice;
import cn.edu.zut.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeDao noticeDao;
    @Override
    public void add(Notice notice){ noticeDao.add(notice); }
    @Override
    public void deleteById(int _id){ noticeDao.deleteById(_id); }
    @Override
    public void update(Notice notice){ noticeDao.update(notice); }
    @Override
    public List<Notice> findAll(){ return noticeDao.findAll(); }
    @Override
    public Notice findByNoticeId(int _id){ return noticeDao.findByNoticeId(_id); }
    @Override
    public List<Notice> findByTitle(String title){ return noticeDao.findByTitle(title); }
    @Override
    public int findEmptyNoticeId(){
        List<Notice> list=noticeDao.findAllByOrder();
        for(int i=0;i<list.size();i++){
            if(list.get(i).get_id()!=i)return i;
        }
        return list.size();
    }
}
